﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="frmRegistroMatrizDecision.aspx.cs" Inherits="sistema_cotizacion_frmRegistroMatrizDecision" culture="auto" meta:resourcekey="PageResource1" uiculture="auto" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>

    <link href="../../kendoui.web/content/shared/styles/examples-offline.css" rel="stylesheet"/>
    <link href="../../kendoui.web/styles/kendo.common.min.css" rel="stylesheet"/>
    <link href="../../kendoui.web/styles/kendo.default.min.css" rel="stylesheet"/>

    <script src="../../kendoui.web/js/jquery.min.js" type="text/javascript"></script>
    <script src="../../kendoui.web/js/kendo.web.min.js" type="text/javascript"></script>
    <script src="../../kendoui.web/content/shared/js/console.js" type="text/javascript"></script>
    <style type="text/css">
        .style1
        {
            height: 19px;
        }
        .style2
        {
            width: 27%;
        }
        .style3
        {
            height: 12px;
        }
        .style4
        {
            height: 19px;
            width: 268435392px;
        }
        .style5
        {
            width: 21%;
        }
        .style6
        {
            width: 26%;
        }
    </style>
</head>
<body>
    <div id="frmContainer" class="k-content">
    <table border="0" width="100%">
    <tr>
        <td colspan="8" align="center"><h2>Generar Matriz Decisión</h2></td>
    </tr>
    <tr>
        <td colspan="8" align="left">Seleccionar Ramo y Aseguradora</td>
    </tr>
    <tr>
        <td colspan="8" align="center">&nbsp;</td>
    </tr>
    <tr> <td colspan="2" align="left" class="style1">Aseguradora:</td>
        <td colspan="2" align="left" class="style1"><input id="cboAseguradora" style="width: 300px" /></td>      
     </tr>
    <tr>
        <td colspan="2" align="left" class="style1">Tipo Seguro:</td>
        <td colspan="2" align="left" class="style1"><input id="cboTipoSeguro" style="width: 300px" /></td>
        <td colspan="2" align="left" class="style1">Ramo:</td>
        <td colspan="2" align="left" class="style4"><input id="cboRamo"style="width: 314px" /></td>
    </tr>
    <tr>
        <td colspan="8" align="center">           
            <hr/></td>
    </tr>
    <tr>
        <td colspan="8" align="left">Seleccionar las condiciones de matriz</td>
    </tr>    
    <tr id="Condicion" style="display:none;width:100%">
      <tr><td colspan="8" align="center" class="style2"><form name="form1" action=""><div id="grdEvento"></div></form></td></tr>        
      <tr>
         <td colspan="8" align="center"><button class="k-button" id="Button1" style="width:160px;"><span class="k-icon k-i-tick"></span>&nbsp;Generar Reglas</button></td>
       </tr>    
    </tr>

     <tr>
        <td colspan="8" align="center"><hr /></td>
    </tr>
    <tr>
        <td colspan="8" align="left">Asignar las reglas para las condiciones de la Matriz</td>
    </tr>
    <tr>
        <td colspan="8" align="center">&nbsp;</td>
    </tr>
    <tr id="reglas" style="display:none;width:100%">
       <td colspan="8" align="center" class="style2"><form name="form1" action="">
      <div id="grdReglas"></div></form></td>        
    </tr>        
        
     
    <tr>
        <td colspan="8" align="center"><hr /></td>
    </tr>
    <tr>
        <td colspan="8" align="center">
            <button class="k-button" id="btnGrabar" style="width:160px;"><span class="k-icon k-i-tick"></span>&nbsp;Grabar Matriz</button>&nbsp;&nbsp;<button class="k-button" id="btnCancelar" style="width:160px;"><span class="k-icon k-i-close"></span>&nbsp;Cancelar</button>
        </td>
    </tr>
    </table>

    <script type="text/javascript">

        $(document).ready(function () {

            var cboTipoSeguro = $("#cboAseguradora").kendoComboBox({
                filter: "startswith",
                placeholder: "Seleccionar Aseguradora...",
                dataTextField: "dAseguradora",
                dataValueField: "cAseguradora",
                dataSource: {
                    transport: {
                        read: {
                            url: "http://localhost/Gra.Seguros.Servicio/MatrizDecision.svc/listarAseguradoras",
                            data: {
                                Accept: "application/json"
                            }
                        }
                    }
                }
            }).data("kendoComboBox");


            var cboTipoSeguro = $("#cboTipoSeguro").kendoComboBox({
                change: onChange_cboTipoSeguro,
                filter: "startswith",
                placeholder: "Seleccionar tipo de seguro...",
                dataTextField: "dTipoSeguro",
                dataValueField: "cTipoSeguro",
                dataSource: {
                    transport: {
                        read: {
                            url: "http://localhost/Gra.Seguros.Servicio/CotizacionSeguro.svc/listarTipoSeguros",
                            data: {
                                Accept: "application/json"
                            }
                        }
                    }
                }
            }).data("kendoComboBox");


            var existe_cboRamo = false;
            function onChange_cboTipoSeguro() {
                existe_cboRamo = true;
                $("#cboRamo").text("");
                $("#cboRamo").val("");
                var cboRamo = $("#cboRamo").kendoComboBox({            
                    filter: "startswith",
                    placeholder: "Seleccionar ramo...",
                    dataTextField: "dRamo",
                    dataValueField: "cRamo",
                    dataSource: {
                        transport: {
                            read: {
                                url: "http://localhost/Gra.Seguros.Servicio/CotizacionSeguro.svc/listarRamos/" + cboTipoSeguro.value(),
                                data: {
                                    Accept: "application/json"
                                }
                            }
                        }
                    }
                }).data("kendoComboBox");
            }

            
                var grdEventoData;
                var _cClaseEvento = "1";

                grdEventoData = new kendo.data.DataSource(
                {                    
                    transport: {
                        read: {
                            
                            url: "http://localhost/Gra.Seguros.Servicio/MatrizDecision.svc/listarEventos/" + _cClaseEvento,
                            data: {
                                Accept: "application/json"
                            }
                        }
                    },
                    pageSize: 10
                });

            var grdEvento = $("#grdEvento").kendoGrid({
                    dataSource: grdEventoData,
                    groupable: false,
                    sortable: true,
                    pageable: {
                        refresh: true,
                        pageSizes: false
                    },
                    selectable: "multiple",
                    dataBound: function () {
                        var grid = this;
                        grid.table.find("tr").find("td:first input")
                            .change(function (e) {
                                var checkbox = $(this);
                                var selected = grid.table.find("tr").find("td:first input:checked").closest("tr");
                                grid.clearSelection();
                                if (selected.length) {
                                    grid.select(selected);
                                }
                            });
                    },
                    columns: [
                            { width: 16, headerTemplate: '<input id="checkAll" type="checkbox" onclick="ChequearTodos(this);" />', template: '<input id="${cEvento}" type="checkbox" />', filterable: false, sortable: false },
                            { width: 70, field: "cEvento", title: "Num. Evento" },
                            { width: 70, field: "dEvento", title: "Evento" },
                            { width: 70, field: "dTipoEvento", title: "Tipo Evento" },
                            { width: 30, field: "nValMin", title: "Valor Mínimo" },
                            { width: 30, field: "nValMax", title: "Valor Máximo" },
                            { width: 30, field: "nIntervalor", title: "Intervalo" },
                            { width: 30, field: "dValorDefecto", title: "Valor Actual" }
                        ]
                }).data("kendoGrid");   

            

        });

    </script>

    </div>
</body>
</html>
